﻿using Mathmall.Administration.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Mathmall.Administration.Data
{
    public class CategoryBrandRelationEntityTypeConfiguration : IEntityTypeConfiguration<CategoryBrandRelation>
    {
        public void Configure(EntityTypeBuilder<CategoryBrandRelation> builder)
        {
            // 不使用output子句
            builder.ToTable(table => table.UseSqlOutputClause(false));

            builder
                .ToTable(nameof(CategoryBrandRelation))
                .ToTable(tableBuilder => tableBuilder.HasComment("品牌分类关联"));

            builder
                .HasKey(categoryBrandRelation => categoryBrandRelation.CategoryBrandRelationID)
                .HasName("CategoryBrandRelationID");

            builder
                .Property(categoryBrandRelation => categoryBrandRelation.BrandID)
                .HasColumnName("BrandID")
                .HasColumnType("int")
                .HasComment("品牌id")
                .IsRequired(false);

            builder
                .Property(categoryBrandRelation => categoryBrandRelation.CategoryID)
                .HasColumnName("CategoryID")
                .HasColumnType("int")
                .HasComment("分类id")
                .IsRequired(false);

            builder
                .Property(categoryBrandRelation => categoryBrandRelation.BrandName)
                .HasColumnName("BrandName")
                .HasColumnType("nvarchar(255)")
                .HasComment("品牌名称")
                .IsRequired(false);

            builder
                .Property(categoryBrandRelation => categoryBrandRelation.CategoryName)
                .HasColumnName("CategoryName")
                .HasColumnType("nvarchar(255)")
                .HasComment("分类名称")
                .IsRequired(false);

            builder
                .Property(category => category.CreateTime)
                .HasColumnName("CreateTime")
                .HasColumnType("datetime")
                .HasComment("创建时间")
                .IsRequired(false);

            builder
                .Property(category => category.LastUpdateTime)
                .HasColumnName("LastUpdateTime")
                .HasColumnType("datetime")
                .HasComment("最后更新时间")
                .IsRequired(false);
        }
    }
}
